<template>
	<div>
	
		<el-row class="bg1">
			<el-col :span="24">
				<h3 class="baseHeader" style="text-align: left">DCU 限幅参数</h3>
				<el-row>
					<el-form :inline="true" ref="doorForm" :model="doorForm" style="display: flex; padding: 0 4.1vw">
						<el-form-item prop="dcu" class="doorNuTxt" label="门控单元编号："
							style="margin-right: 2.6vw; margin-bottom: 0">
							<el-select v-model="doorForm.dcu" filterable multiple collapse-tags clearable
								placeholder="请选择" style="width: 12vw;min-width: 155px;" @change="doorChange">
								<el-checkbox v-model="checkOptions.checkAll" :style="{ padding: '5px 20px' }"
									:indeterminate="checkOptions.isIndeterminate" @change="handleCheckAllChange">
									全选
								</el-checkbox>
								<el-option v-for="(item, index) in options" :key="index" :label="item.dcu"
									:value="item.dcu"></el-option>
							</el-select>
						</el-form-item>
						<div class="baseInfoBtn" style="display: flex; justify-content: end">
							<el-button class="btn1" type="primary" @click="getAmpLimitData()">读取</el-button>
							<el-button class="btn7" type="primary" @click="writeAmpLimit()">写入</el-button>
							<el-button class="btn7" type="primary" @click="historyAmpLimitLoad()">加载</el-button>
							<el-button class="btn6" type="primary" @click="AmpLimitsave()">保存</el-button>
							<el-button class="btn4" type="primary" v-loading.fullscreen.lock="fullscreenLoading" @click="exportHandle()">导出所有数据</el-button>
						</div>
					</el-form>
				</el-row>
				<div class="baseInfo">
					<div class="baseInfoContent">
						<el-form :inline="true" :rules="baseRule" ref="baseForm" :model="baseForm">
							<el-row>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="开门加速段正限幅：" prop="openDoorSpeedUpPosiLimit">
										<el-input-number v-model="baseForm.openDoorSpeedUpPosiLimit" :readonly="DCUStatus" placeholder=""
											clearable :min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="关门加速段正限幅：" prop="closeDoorSpeedUpPosiLimit">
										<el-input-number v-model="baseForm.closeDoorSpeedUpPosiLimit" :min='0' :max='850' :precision="0"
											:readonly="DCUStatus" placeholder="" clearable
											class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
							</el-row>
							<el-row>
								<div class="baseInfo1">
									<el-form-item label="开门加速段负限幅：" prop="openDoorSpeedUpNegaLimit">
										<el-input-number v-model="baseForm.openDoorSpeedUpNegaLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
								<div class="baseInfo1">
									<el-form-item label="关门加速段负限幅：" prop="closeDoorSpeedUpNegaLimit">
										<el-input-number v-model="baseForm.closeDoorSpeedUpNegaLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
							</el-row>
							<el-row>
								<div class="baseInfo1">
									<el-form-item label="开门匀速段正限幅：" prop="openDoorSpeedConstantPosiLimit">
										<el-input-number v-model="baseForm.openDoorSpeedConstantPosiLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
								<div class="baseInfo1">
									<el-form-item label="关门匀速段正限幅：" prop="closeDoorSpeedConstantPosiLimit">
										<el-input-number v-model="baseForm.closeDoorSpeedConstantPosiLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
							</el-row>
							<el-row>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="开门匀速段负限幅：" prop="openDoorSpeedConstantNegaLimit">
										<el-input-number v-model="baseForm.openDoorSpeedConstantNegaLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="关门匀速段负限幅：" prop="closeDoorSpeedConstantNegaLimit">
										<el-input-number v-model="baseForm.closeDoorSpeedConstantNegaLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
							</el-row>
							<el-row>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="开门减速段正限幅：" prop="openDoorSpeedDownPosiLimit">
										<el-input-number v-model="baseForm.openDoorSpeedDownPosiLimit" :readonly="DCUStatus"
											placeholder="" clearable :min='0' :max='850' :precision="0"
											class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="关门减速段正限幅：" prop="closeDoorSpeedDownPosiLimit">
										<el-input-number v-model="baseForm.closeDoorSpeedDownPosiLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
							</el-row>
							<el-row> </el-row>
							<el-row>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="开门减速段负限幅：" prop="openDoorSpeedDownNegaLimit">
										<el-input-number v-model="baseForm.openDoorSpeedDownNegaLimit" type="number"
											clearable :min='0' :max='850' :precision="0" class="input-width">
										</el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
								<div class="baseInfo1">
									<el-form-item label="关门减速段负限幅：" prop="closeDoorSpeedDownNegaLimit">
										<el-input-number v-model="baseForm.closeDoorSpeedDownNegaLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
							</el-row>
							<el-row>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="开门慢速段正限幅：" prop="openDoorSpeedSlowPosiLimit">
										<el-input-number v-model="baseForm.openDoorSpeedSlowPosiLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="关门慢速段正限幅：" prop="closeDoorSpeedSlowPosiLimit">
										<el-input-number v-model="baseForm.closeDoorSpeedSlowPosiLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
							</el-row>
							<el-row>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="开门慢速段负限幅：" prop="openDoorSpeedSlowNegaLimit">
										<el-input-number v-model="baseForm.openDoorSpeedSlowNegaLimit" :readonly="DCUStatus" clearable
											:min='0' :max='950' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~950)</span>
								</div>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="关门慢速段负限幅：" prop="closeDoorSpeedSlowNegaLimit">
										<el-input-number v-model="baseForm.closeDoorSpeedSlowNegaLimit" :readonly="DCUStatus"
											clearable :min='0' :max='950' :precision="0"
											class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~950)</span>
								</div>
							</el-row>
							<el-row>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="开门遇障正限幅：" prop="openDoorObstaclesPosiLimit">
										<el-input-number v-model="baseForm.openDoorObstaclesPosiLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="关门遇障正限幅：" prop="closeDoorObstaclesPosiLimit">
										<el-input-number v-model="baseForm.closeDoorObstaclesPosiLimit" :readonly="DCUStatus"
											clearable :min='0' :max='850' :precision="0"
											class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
							</el-row>
							<el-row>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="开门遇障负限幅：" prop="openDoorObstaclesNegaLimit">
										<el-input-number v-model="baseForm.openDoorObstaclesNegaLimit" :readonly="DCUStatus" clearable
											:min='0' :max='850' :precision="0" class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
								<div class="baseInfo1 doorNu1">
									<el-form-item label="关门遇障负限幅：" prop="closeDoorObstaclesNegaLimit">
										<el-input-number v-model="baseForm.closeDoorObstaclesNegaLimit" :readonly="DCUStatus"
											clearable :min='0' :max='850' :precision="0"
											class="input-width"></el-input-number>
									</el-form-item>
									<span class="company company1">(0~850)</span>
								</div>
							</el-row>
						</el-form>
					</div>
				</div>
			</el-col>
		</el-row>
		<!-- PID参数保存 -->
		<el-dialog :visible.sync="saveVisible" title="DCU 限幅参数保存" :close-on-click-modal="false"
			:close-on-press-escape="false">
			<el-form :model="saveForm" ref="saveForm" :rules="saveRule" @keyup.enter.native="confirm()"
				label-width="200px">
				<el-form-item prop="name" label="DCU 限幅参数保存名称">
					<el-input v-model="saveForm.name" placeholder="DCU 限幅参数保存名称"></el-input>
				</el-form-item>
			</el-form>
			<template slot="footer">
				<el-button @click="saveVisible = false">{{ $t("cancel") }}</el-button>
				<el-button type="primary" @click="confirm()">{{
					$t("confirm")
				}}</el-button>
			</template>
		</el-dialog>
		<history-or-update v-if="historyVisible" ref="historyForm" @refreshDataList="init" @getHistory="getHistory">
		</history-or-update>
	</div>
</template>

<script>
	import debounce from "lodash/debounce";
	import mixinViewModule from "@/mixins/view-module";
	import AddOrUpdate from "./sysParam-add-or-update";
	import dcuUpgrade from "./dcuUpgrade.vue";
	import utils from "@/utils/utils";
	import Cookies from "js-cookie";
	import operData from "../oper/oper-data.vue";
	import historyOrUpdate from "./AmpLimit-add-or-update.vue";
	import qs from 'qs'
	import { getOrder,getStep} from "@/utils";
	export default {
		mixins: [mixinViewModule],
		components: {
			AddOrUpdate,
			dcuUpgrade,
			operData,
			historyOrUpdate,
		},
		data() {
			return {
				mixinViewModuleOptions: {
					createdIsNeed: false,
					deleteURL: "",
					deleteIsBatch: true,
					activatedIsNeed: false,
					exportURL: "/psc/dcuAmpLimitparameters/export",
				},
				dataForm: {
				},
				options: [],
				DCUoptions: [], //DCU的options
				baseForm: {
					openDoorSpeedUpPosiLimit: undefined,
					openDoorSpeedUpNegaLimit: undefined,
					openDoorSpeedConstantPosiLimit: undefined,
					openDoorSpeedConstantNegaLimit: undefined,
					openDoorSpeedDownPosiLimit: undefined,
					openDoorSpeedDownNegaLimit: undefined,
					openDoorSpeedSlowPosiLimit: undefined,
					openDoorSpeedSlowNegaLimit: undefined,
					openDoorObstaclesPosiLimit: undefined,
					openDoorObstaclesNegaLimit: undefined,
					closeDoorSpeedUpPosiLimit: undefined,
					closeDoorSpeedUpNegaLimit: undefined,
					closeDoorSpeedConstantPosiLimit: undefined,
					closeDoorSpeedConstantNegaLimit: undefined,
					closeDoorSpeedDownPosiLimit: undefined,
					closeDoorSpeedDownNegaLimit: undefined,
					closeDoorSpeedSlowPosiLimit: undefined,
					closeDoorSpeedSlowNegaLimit: undefined,
					closeDoorObstaclesPosiLimit: undefined,
					closeDoorObstaclesNegaLimit: undefined,
				},
				doorIndex: "", //门的编号,
				jdNumber: "", //进度条的数据显示
				checkOptions: {
					isIndeterminate: false,
					checkAll: false,
				},
				PIDForm: {
					dcu: "",
					pidValue: ""
				},
				doorForm: {
					dcu: ''
				},
				checkOptions1: {
					isIndeterminate: false,
					checkAll: false,
				},
				DCUStatus: false,
				stepUp: 0, //上行门的step值
				stepDown: 0, //下行门的step值
				saveVisible: false, //PID保存
				saveForm: {
					name: "",
				},
				historyVisible: false, //加载数据
				defaultStatus:false
			};
		},
		activated() {
			this.init();
		},
		mounted() {},
		destroyed() {},
		computed: {
			baseRule() {
				return {
					openDoorSpeedUpPosiLimit: [{
						required: true,
						message: "开门加速段正限幅不能为空",
						trigger: "blur",
					}],
					openDoorSpeedUpNegaLimit: [{
						required: true,
						message: "开门加速段负限幅不能为空",
						trigger: "blur",
					}],
					openDoorSpeedConstantPosiLimit:[{
						required: true,
						message: "开门匀速段正限幅不能为空",
						trigger: "blur",
					}],
					openDoorSpeedConstantNegaLimit:[{
						required: true,
						message: "开门匀速段负限幅不能为空",
						trigger: "blur",
					}],
					openDoorSpeedDownPosiLimit:[{
						required: true,
						message: "开门减速段正限幅不能为空",
						trigger: "blur",
					}],
					openDoorSpeedDownNegaLimit:[{
						required: true,
						message: "开门减速段负限幅不能为空",
						trigger: "blur",
					}],
					openDoorSpeedSlowPosiLimit:[{
						required: true,
						message: "开门慢速段正限幅不能为空",
						trigger: "blur",
					}],
					openDoorSpeedSlowNegaLimit:[{
						required: true,
						message: "开门慢速段负限幅不能为空",
						trigger: "blur",
					}],
					openDoorObstaclesPosiLimit:[{
						required: true,
						message: "开门遇障正限幅不能为空",
						trigger: "blur",
					}],
					openDoorObstaclesNegaLimit:[{
						required: true,
						message: "开门遇障负限幅不能为空",
						trigger: "blur",
					}],
					closeDoorSpeedUpPosiLimit:[{
						required: true,
						message: "关门加速段正限幅不能为空",
						trigger: "blur",
					}],
					closeDoorSpeedUpNegaLimit:[{
						required: true,
						message: "关门加速段负限幅不能为空",
						trigger: "blur",
					}],
					closeDoorSpeedConstantPosiLimit:[{
						required: true,
						message: "关门匀速段正限幅不能为空",
						trigger: "blur",
					}],
					closeDoorSpeedConstantNegaLimit:[{
						required: true,
						message: "关门匀速段负限幅不能为空",
						trigger: "blur",
					}],
					closeDoorSpeedDownPosiLimit:[{
						required: true,
						message: "关门减速段正限幅不能为空",
						trigger: "blur",
					}],
					closeDoorSpeedDownNegaLimit:[{
						required: true,
						message: "关门减速段负限幅不能为空",
						trigger: "blur",
					}],
										closeDoorSpeedSlowPosiLimit:[{
						required: true,
						message: "关门慢速段正限幅不能为空",
						trigger: "blur",
					}],
					closeDoorSpeedSlowNegaLimit:[{
						required: true,
						message: "关门慢速段负限幅",
						trigger: "blur",
					}],
					closeDoorObstaclesPosiLimit:[{
						required: true,
						message: "关门遇障正限幅不能为空",
						trigger: "blur",
					}],
					closeDoorObstaclesNegaLimit:[{
						required: true,
						message: "关门遇障负限幅不能为空",
						trigger: "blur",
					}],
				};
			},
			saveRule() {
				return {
					name: [{
						required: true,
						message: "DCU限幅参数保存名称不能为空",
						trigger: "blur",
					}, ],
				};
			},
		},
		watch: {},
		methods: {
			init() {
				//获取门的信息
				var p0 = new Promise((resolve, reject) => {
					this.getdoorList(() => {
						resolve();
					});
				});
				Promise.all([p0]).then(() => {});
			},
			//门的编号
			getdoorList(callback) {
				this.DCUoptions = [];
				this.yjoptions = [];
				this.$http
					.get("/psc/door/getDoor")
					.then((res) => {
						//获取上下行数据要增加和减少的值-----2023年5月26日
						this.stepUp = getStep(res.data.data.up)
						this.stepDown = getStep(res.data.data.down)
						// console.log( this.stepUp,this.stepDown,'上下行的step的值')
						//获取上下行数据要增加和减少的值-----2023年5月26日
						if (this.dataForm.stationSide == 1) {
							res.data.data.up.forEach((item) => {
								if (item.doorType == 1) {
									this.DCUoptions.push(item);
								}
							});
						} else if (this.dataForm.stationSide == 0) {
							res.data.data.down.forEach((item) => {
								if (item.doorType == 1) {
									this.DCUoptions.push(item);
								}
							});
						}
						this.options = res.data.data.up.concat(res.data.data.down);
						for (var i = 0; i < this.options.length; i++) {
							if (this.options[i].doorType === 2) {
								this.yjoptions.push(this.options[i])
							}
							if (
								this.options[i].doorType === 0 ||
								this.options[i].doorType === 2
							) {
								this.options.splice(i, 1); // 将使后面的元素依次前移，数组长度减1
								i--; // 如果不减，将漏掉一个元素
							}
						}
						// this.baseForm.dcu = this.options[0].dcu
						if (this.options.length !== 0) {
							this.stationSide = this.options[0].type;
						}
						// console.log(this.yjoptions, '应急数据')
						if (callback) {
							callback();
						}
					})
					.then(() => {
						// this.getDCUData()
					});
			},
			// 流向全选
			handleCheckAllChange(e) {
				this.doorForm.dcu = e ? this.options.map((item) => item.dcu) : [];
				this.checkOptions.isIndeterminate = false;
			},
			handleCheckAllChange1(e) {
				this.PIDForm.dcu = e ? this.options.map((item) => item.dcu) : [];
				this.checkOptions1.isIndeterminate = false;
			},
			//改变门的编号
			doorChange() {
				const nowLength = this.doorForm.dcu.length;
				this.checkOptions.isIndeterminate =
					nowLength > 0 && nowLength < this.options.length;
				this.checkOptions.checkAll = nowLength == this.options.length;
				this.$forceUpdate();
			},
			PIDChange() {
				const nowLength = this.PIDForm.dcu.length;
				this.checkOptions1.isIndeterminate =
					nowLength > 0 && nowLength < this.options.length;
				this.checkOptions1.checkAll = nowLength == this.options.length;
				this.$forceUpdate();
			},
			// 配置
			slideConfig() {
				var dcuId = [];
				for (var i = 0; i < this.PIDForm.dcu.length; i++) {
					for (var j = 0; j < this.options.length; j++) {
						if (Number(this.PIDForm.dcu[i]) == this.options[j].dcu && this.options[j].stationSide == 1) {
							let num1 = Number(this.PIDForm.dcu[i]) - this.stepUp;
							dcuId.push(num1);
						} else if (Number(this.PIDForm.dcu[i]) == this.options[j].dcu && this.options[j].stationSide ==
							0) {
							let num1 = Number(this.PIDForm.dcu[i]) - this.stepDown + 128;
							dcuId.push(num1);
						}
					}
				}
				var obj = {
					"dcuArr": dcuId,
					"slideFun": this.PIDForm.pidValue
				}
				this.$http
					.post("/psc/dcu/slideDoorConfig", obj).then((res) => {
						if (res.data.code !== 0) {
							return this.$message.error(res.data.msg);
						}
						this.$message({
							message: this.$t('prompt.success'),
							type: 'success',
							duration: 500,
							onClose: () => {

							}
						})
					})
			},
			//读取pid参数
			getAmpLimitData() {
				this.$http
					.get("/psc/dcu/readAmpLimit/" + this.returnDoorId()[0])
					.then((res) => {
						if (res.data.code !== 0) {
							if (!this.defaultStatus) {
								return this.$message.error(res.data.msg);
							}
							this.getAmpLimitValue()
						}
						if (res.data.code == 0 && res.data.data !== null) {
							if (!this.defaultStatus) {
								this.$message({
									message: this.$t("prompt.success"),
									type: "success",
									duration: 500,
								});
							}
							this.getAmpLimitValue(res.data.data);
						}
					});
			},
			getAmpLimitValue(val) {
				this.baseForm.openDoorSpeedUpPosiLimit = val ? val.openDoorSpeedUpPosiLimit : undefined;
				this.baseForm.openDoorSpeedUpNegaLimit = val ? val.openDoorSpeedUpNegaLimit : undefined;
				this.baseForm.openDoorSpeedConstantPosiLimit = val ? val.openDoorSpeedConstantPosiLimit : undefined;
				this.baseForm.openDoorSpeedConstantNegaLimit = val ? val.openDoorSpeedConstantNegaLimit : undefined;
				this.baseForm.openDoorSpeedDownPosiLimit = val ? val.openDoorSpeedDownPosiLimit : undefined;
				this.baseForm.openDoorSpeedDownNegaLimit = val ? val.openDoorSpeedDownNegaLimit : undefined;
				this.baseForm.openDoorSpeedSlowPosiLimit = val ? val.openDoorSpeedSlowPosiLimit : undefined;
				this.baseForm.openDoorSpeedSlowNegaLimit = val ? val.openDoorSpeedSlowNegaLimit : undefined;
				this.baseForm.openDoorObstaclesPosiLimit = val ? val.openDoorObstaclesPosiLimit : undefined;
				this.baseForm.openDoorObstaclesNegaLimit = val ? val.openDoorObstaclesNegaLimit : undefined;
				this.baseForm.closeDoorSpeedUpPosiLimit = val ? val.closeDoorSpeedUpPosiLimit : undefined;
				this.baseForm.closeDoorSpeedUpNegaLimit = val ? val.closeDoorSpeedUpNegaLimit : undefined;
				this.baseForm.closeDoorSpeedConstantPosiLimit = val ? val.closeDoorSpeedConstantPosiLimit : undefined;
				this.baseForm.closeDoorSpeedConstantNegaLimit = val ? val.closeDoorSpeedConstantNegaLimit : undefined;
				this.baseForm.closeDoorSpeedDownPosiLimit = val ? val.closeDoorSpeedDownPosiLimit : undefined;
				this.baseForm.closeDoorSpeedDownNegaLimit = val ? val.closeDoorSpeedDownNegaLimit : undefined;
				this.baseForm.closeDoorSpeedSlowPosiLimit = val ? val.closeDoorSpeedSlowPosiLimit : undefined;
				this.baseForm.closeDoorSpeedSlowNegaLimit = val ? val.closeDoorSpeedSlowNegaLimit : undefined;
				this.baseForm.closeDoorObstaclesPosiLimit = val ? val.closeDoorObstaclesPosiLimit : undefined;
				this.baseForm.closeDoorObstaclesNegaLimit = val ? val.closeDoorObstaclesNegaLimit : undefined;
			},
			//返回相对应的门的ID
			returnDoorId() {
				var doorNum = [];
				for (var i = 0; i < this.doorForm.dcu.length; i++) {
					for (var j = 0; j < this.options.length; j++) {
						if (Number(this.doorForm.dcu[i]) == this.options[j].dcu && this.options[j].stationSide == 1) {
							let num1 = Number(this.doorForm.dcu[i]) - this.stepUp;
							doorNum.push(num1);
						} else if (Number(this.doorForm.dcu[i]) == this.options[j].dcu && this.options[j].stationSide ==
							0) {
							let num1 = Number(this.doorForm.dcu[i]) - this.stepDown + 128;
							doorNum.push(num1);
						}
					}
				}
				return doorNum;
			},
			writeAmpLimit() {
				this.$confirm('此操作将写入DCU限幅参数, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					if (this.doorForm.dcu.length !== 0) {
						this.readDataStatus = false
						var obj = this.paramObj();
						this.$http.post("/psc/dcu/writeAmpLimitParams", obj).then((res) => {
							if (res.data.code !== 0) {
								// this.defaultStatus = true
								//恢复读取值
								// this.getAmpLimitData()
								return this.$message.error(res.data.msg);
							}
							this.$message({
								message: this.$t("prompt.success"),
								type: "success",
								duration: 500,
								onClose: () => {
									this.visible = false;
									// this.defaultStatus = true
									//恢复读取值
									// this.getAmpLimitData()
								},
							});
						});
					} else {
						return this.$message.error("请选择门控单元编号");
					}
				})
			},
			//存储数据专用
			paramObj() {
				var obj = {
					dcuArr: this.returnDoorId(),
					...this.baseForm,
				};
				console.log(obj, "数值显示");
				return obj;
			},
			// 保存数据
			AmpLimitsave() {
				if (this.doorForm.dcu.length !== 0) {
					this.saveVisible = true;
					this.$nextTick(() => {
						this.$refs["saveForm"].resetFields();
					});
				} else {
					return this.$message.error("请选择门控单元编号");
				}
			},
			//保存数据确定
			confirm() {
				this.$refs["saveForm"].validate((valid) => {
					if (!valid) {
						return false;
					}
					this.$refs["baseForm"].validate((status) => {
						if (!status) {
							return false;
						}
						var obj = this.paramObj();
						obj = {
							name: this.saveForm.name,
							...obj,
						};
						this.$http.post("/psc/dcuAmpLimitparameters", obj).then((res) => {
							if (res.data.code !== 0) {
								this.defaultStatus = true
								//恢复读取值
								this.getAmpLimitData()
								return this.$message.error(res.msg);
							}
							this.$message({
								message: this.$t("prompt.success"),
								type: "success",
								duration: 500,
								onClose: () => {
									this.saveVisible = false;
									this.defaultStatus = true
									//恢复读取值
									this.getAmpLimitData()
								},
							});
						});
					})
					
				});
			},
			//加载
			historyAmpLimitLoad() {
				if (this.doorForm.dcu.length > 1) {
					this.$message({
						message: "门控制单元编号只能选一个",
						type: "error",
						duration: 2000,
					});
				} else {
					this.historyVisible = true;
					this.$nextTick(() => {
						this.$refs.historyForm.init();
					});
				}
			},
			//获取历史保存的数据
			getHistory(id) {
				// console.log(id, '保存的id值')
				this.$http.get(`/psc/dcuAmpLimitparameters/${id}`).then((res) => {
					if (res.data.code == 0 && res.data.data !== null) {
						this.$message({
							message: this.$t("prompt.success"),
							type: "success",
							duration: 500,
							onClose: () => {
								this.$nextTick(() => {
									this.getAmpLimitValue(res.data.data);
								});
							},
						});
						
					}
				});
			},
		},
	};
</script>

<style scoped>
	.bg {
		background-color: #fff;
		border-radius: 10px;
		display: flex;
		align-items: center;
		height: 7.6vh;
		line-height: 7.6vh;
		padding: 0 1.8vw;
	}

	.bg>>>.el-form--inline .el-form-item__content,
	.el-form--inline .el-form-item {
		vertical-align: middle !important;
	}

	.bg>>>.el-form-item {
		margin-bottom: 0;
	}

	.bg1 {
		background-color: #fff;
		border-radius: 10px;
		display: flex;
		align-items: center;
		/* height: 83.1vh; */
		/* height: 71vh; */
		padding: 2.1vh 1.5vw;
		margin-top: 10px;
	}

	.homeTuTxt {
		width: 16px;
		font-size: 18px;
		font-weight: 400;
		word-wrap: break-word;
		word-break: normal;
		line-height: 40px;
		color: rgba(0, 65, 135, 1);
	}

	.bg1 .el-col {
		height: 100%;
	}

	.baseHeader {
		margin: 0;
		font-size: 18px;
		font-weight: 500;
		color: rgba(46, 48, 51, 1);
	}

	.baseHeader1 {
		text-align: left;
		font-size: 16px;
		display: flex;
		align-items: center;
	}

	.dcuTxt {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 10px;
	}


	.baseInfo {
		display: flex;
		width: 100%;
		/* height: 64vh; */
		padding: 0 2.1vw;
		/* background: rgba(0, 123, 255, 0.1); */
		border-radius: 10px;
		align-items: center;
		margin-top: 1.3vh;
	}

	.baseInfozd {
		height: 34.3vh;
	}

	.baseInfoContent {
		width: 100%;
		height: 100%;
		/* padding-left: 1.9vw; */
	}

	.baseInfoContent>>>.el-row {
		display: flex;
		/* justify-content: space-between; */
	}

	.baseInfoContent>>>.el-input__inner {
		height: 100%;
		text-align: center;
		padding: 0;
	}

	.baseInfoContent>>>.el-form--inline .el-form-item__content,
	.el-form--inline .el-form-item {
		vertical-align: middle !important;
	}

	.baseInfoContent>>>.el-form-item {
		/* margin-bottom: 0; */
	}

	.baseInfoContent>>>.el-form {
		height: 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-evenly;
	}

	.baseInfo1 {
		width: 50%;
		display: flex;
		justify-content: flex-start;
		position: relative;
	}

	.baseInfo1>>>.el-form-item__label {
		/* width: 11vw; */
		width: 180px;
		font-size: 14px;
		font-weight: 400;
		color: rgba(46, 48, 51, 1);
	}

	.company {
		width: 2.5vw;
		height: 2.7vh;
		line-height: 2.7vh;
		margin-top: 0.8vh;
		font-size: 14px;
	}

	.baseInfo2 {
		padding-left: 11vw;
	}

	.baseInfo2 div {
		width: 7.8vw;
		display: flex;
		justify-content: center;
	}

	.baseInfoBtn>>>.el-button--primary:focus,
	.baseInfoBtn>>>.el-button--primary:hover {
		border-radius: 10px;
		background: rgba(25, 77, 138, 1) !important;
	}

	.baseInfoBtn>>>.el-button--primary {
		border-radius: 10px;
		background: rgba(25, 77, 138, 1) !important;
		font-size: 16px;
		font-weight: 400;
		color: rgba(255, 255, 255, 1);
	}

	.baseInfoBtnAll {
		width: 95%;
		justify-content: flex-end;
	}

	.danwei {
		font-size: 14px;
		font-weight: 400;
		color: rgba(46, 48, 51, 1);
	}

	.baseInfoBtnRight {
		position: absolute;
		right: 1.8vw;
		top: 2vh;
		height: 96%;
		width: 7.8vw;
	}

	.baseInfoBtnRight .baseInfoBtn {
		display: flex;
		flex-direction: column;
		height: 100%;
		justify-content: space-evenly;
	}

	.baseInfoBtnRight>>>.baseInfoBtn1,
	.PEDCBtn>>>.baseInfoBtn1,
	.PEDCInfo>>>.baseInfoBtn1 {
		background: rgba(42, 130, 228, 1) !important;
		border-color: rgba(42, 130, 228, 1) !important;
	}

	.baseInfoBtnRight>>>.baseInfoBtn1:focus,
	.baseInfoBtnRight>>>.baseInfoBtn1:hover,
	.PEDCBtn>>>.baseInfoBtn1:focus,
	.PEDCBtn>>>.baseInfoBtn1:hover,
	.PEDCInfo>>>.baseInfoBtn1:focus,
	.PEDCInfo>>>.baseInfoBtn1:hover {
		background: rgba(42, 130, 228, 1) !important;
		border-color: rgba(42, 130, 228, 1) !important;
	}

	.baseInfoBtnRight>>>.baseInfoBtn2,
	.PEDCBtn>>>.baseInfoBtn2,
	.PEDCInfo>>>.baseInfoBtn2 {
		background: rgba(255, 87, 51, 1) !important;
		border-color: rgba(255, 87, 51, 1) !important;
	}

	.baseInfoBtnRight>>>.baseInfoBtn2:focus,
	.baseInfoBtnRight>>>.baseInfoBtn2:hover,
	.PEDCBtn>>>.baseInfoBtn2:focus,
	.PEDCBtn>>>.baseInfoBtn2:hover,
	.PEDCInfo>>>.baseInfoBtn2:focus,
	.PEDCInfo>>>.baseInfoBtn2:hover {
		background: rgba(255, 87, 51, 1) !important;
		border-color: rgba(255, 87, 51, 1) !important;
	}

	.baseInfoBtnRight>>>.baseInfoBtn3 {
		background: rgba(67, 207, 124, 1) !important;
		border-color: rgba(67, 207, 124, 1) !important;
	}

	.baseInfoBtnRight>>>.baseInfoBtn3:focus,
	.baseInfoBtnRight>>>.baseInfoBtn3:hover {
		background: rgba(67, 207, 124, 1) !important;
		border-color: rgba(67, 207, 124, 1) !important;
	}

	.baseInfoBtnRight>>>.baseInfoBtn4 {
		background: rgba(56, 56, 56, 1) !important;
		border-color: rgba(56, 56, 56, 1) !important;
	}

	.baseInfoBtnRight>>>.baseInfoBtn4:focus,
	.baseInfoBtnRight>>>.baseInfoBtn4:hover {
		background: rgba(56, 56, 56, 1) !important;
		border-color: rgba(56, 56, 56, 1) !important;
	}

	.baseInfoBtnRight>>>.el-button {
		padding: 10px 12px;
	}

	.bg2 {
		background-color: #fff;
		border-radius: 10px;
		padding: 2.1vh 1.5vw;
		margin-top: 10px;
		height: 38.1vh;
	}

	.bg3 {
		height: auto !important;
	}

	.bg4 {
		height: 5vh;
		padding: 0;
		line-height: 5vh;
		padding: 0 1.5vw;
	}

	.bg3>>>.el-row {
		height: 100%;
	}

	.PEDCInfo {
		padding: 2vh 2.1vw 0;
		height: calc(100% - 23px);
		display: flex;
		align-items: center;
	}

	.PEDCBtn {
		display: flex;
	}

	.baseInfoEcharts {
		width: 100%;
		height: calc(100% - 23px);
	}

	.doorNuTxt>>>.el-input {
		height: 100%;
		line-height: 35px;
	}

	.doorNu1 {
		justify-content: flex-start;
	}

	.baseInfoBtn>>>.btn1 {
		font-size: 14px;
		font-weight: 400;
		border-radius: 5px;
		color: rgba(255, 255, 255, 1);
		background: rgba(255, 195, 0, 1) !important;
		border-color: rgba(255, 195, 0, 1) !important;
	}

	.baseInfoBtn>>>.btn1:focus,
	.baseInfoBtn>>>.btn1:hover {
		background: rgba(255, 195, 0, 0.8) !important;
		border-color: rgba(255, 195, 0, 1) !important;
		border-radius: 5px !important;
	}

	.baseInfoBtn>>>.btn2 {
		font-size: 14px;
		font-weight: 400;
		border-radius: 5px;
		color: rgba(255, 255, 255, 1);
		background: rgba(67, 207, 124, 1) !important;
		border-color: rgba(67, 207, 124, 1) !important;
	}

	.baseInfoBtn>>>.btn2:focus,
	.baseInfoBtn>>>.btn2:hover {
		background: rgba(67, 207, 124, 1) !important;
		border-color: rgba(67, 207, 124, 1) !important;
		border-radius: 5px !important;
	}

	.baseInfoBtn>>>.btn3 {
		font-size: 14px;
		font-weight: 400;
		border-radius: 5px;
		color: rgba(255, 255, 255, 1);
		background: rgba(255, 141, 26, 1) !important;
		border-color: rgba(255, 141, 26, 1) !important;
	}

	.baseInfoBtn>>>.btn3:focus,
	.baseInfoBtn>>>.btn3:hover {
		background: rgba(255, 141, 26, 1) !important;
		border-color: rgba(255, 141, 26, 1) !important;
		border-radius: 5px !important;
	}

	.baseInfoBtn>>>.btn4,
	.baseInfoBtn>>>.btn5 {
		font-size: 14px;
		font-weight: 400;
		border-radius: 5px;
		color: rgba(255, 255, 255, 1);
		background: rgba(66, 177, 255, 1) !important;
		border-color: rgba(66, 177, 255, 1) !important;
	}

	.baseInfoBtn>>>.btn4:focus,
	.baseInfoBtn>>>.btn4:hover,
	.baseInfoBtn>>>.btn5:focus,
	.baseInfoBtn>>>.btn5:hover {
		background: rgba(66, 177, 255, 0.8) !important;
		border-color: rgba(66, 177, 255, 1) !important;
		border-radius: 5px !important;
	}

	.baseInfoBtn>>>.btn6,
	.baseInfoBtn>>>.btn8 {
		font-size: 14px;
		font-weight: 400;
		border-radius: 5px;
		color: rgba(255, 255, 255, 1);
		background: rgba(67, 207, 124, 1) !important;
		border-color: rgba(67, 207, 124, 1) !important;
	}

	.baseInfoBtn>>>.btn6:focus,
	.baseInfoBtn>>>.btn6:hover,
	.baseInfoBtn>>>.btn8:focus,
	.baseInfoBtn>>>.btn8:hover {
		border-radius: 5px !important;
		background: rgba(67, 207, 124, 0.8) !important;
		border-color: rgba(67, 207, 124, 1) !important;
	}

	.baseInfoBtn>>>.btn7 {
		font-size: 14px;
		font-weight: 400;
		border-radius: 5px;
		color: rgba(255, 255, 255, 1);
		background: rgba(255, 141, 26, 1) !important;
		border-color: rgba(255, 141, 26, 1) !important;
	}

	.baseInfoBtn>>>.btn7:focus,
	.baseInfoBtn>>>.btn7:hover {
		border-radius: 5px !important;
		background: rgba(255, 141, 26, 0.8) !important;
		border-color: rgba(255, 141, 26, 1) !important;
	}

	.baseS {
		margin-left: 2vw;
	}

	.PEDCInfo>>>.el-form-item__label {
		text-align: left;
	}

	.baseInfo>>>.el-form-item--default {
		/* margin-bottom: 0px !important; */
	}

	.progress-bar {
		width: 100%;
		height: 30px;
		overflow: hidden;
		box-sizing: border-box;
		border-radius: 24px;
		background-color: rgba(180, 160, 120, 0.2);
		position: relative;
	}

	.progress-bg {
		width: 0;
		height: 100%;
		overflow: hidden;
		box-sizing: border-box;
		background: rgba(67, 207, 124, 1);
		border-radius: 24px;
		/* animation: panoramic 2s linear infinite;
	  background-size: 32px 100%; */
	}

	.baseInfo1>>>.el-input-number__decrease,
	.baseInfo1>>>.el-input-number__increase {
		height: 94%;
		margin-top: 1%;
		display: none;
	}

	.baseInfo1>>>.el-input-number .el-input {
		height: 100%;
	}

	.company1 {
		position: absolute;
		left: 380px;
		white-space: nowrap;
	}

	.input-width {
		width: 7.8vw;
		height: 3.5vh;
		min-height: 30px;
		min-width: 150px;
	}

	/* @keyframes panoramic{
	  to {
	    width: 100%;
	  }
	} */
</style>